﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace HospitalMedicineTraceability
{
    public partial class frmSupplierCodeCheck : DevComponents.DotNetBar.OfficeForm
    {
        public Dictionary<string, string> m_dictInfo = new Dictionary<string, string>(); // 回传信息(指定对码时用)
        public frmSupplierCodeCheck()
        {
            InitializeComponent();
        }
        #region  1.自定义方法
        /// <summary>
        /// 初始化
        /// </summary>
        private void _init() {
            // 控件赋初始值
            txtCode0.Text = m_dictInfo["SupplierCode_His"];
            txtName0.Text = m_dictInfo["SupplierName_His"];
            txtCode1.Text = m_dictInfo["SupplierCode"];
            txtName1.Text = m_dictInfo["SupplierName"];
        }
        private void _save() {
            // 清除原有数据
            string strSql = "Update TH_Supplier set TaxCode= '',TaxName= '',Linker = '',CodeCheckStatus='未对码',CodeCheckTime = null Where TaxCode = '{0}'";
            strSql = string.Format(strSql, m_dictInfo["SupplierCode"]);
            AppInfo._execSql(strSql);
            // 更改新数据
            strSql = "Update TH_Supplier set TaxCode= '{1}',TaxName= '{2}',CodeCheckStatus='已对码',CodeCheckTime = getDate() Where Code = '{0}'";
            strSql = string.Format(strSql, m_dictInfo["SupplierCode_His"], m_dictInfo["SupplierCode"], m_dictInfo["SupplierName"]);
            if (AppInfo._execSql(strSql) == 1)
            {
                CommFun._messageBoxShow("配送企业对码成功！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult = DialogResult.OK;
            }
            else {
                CommFun._messageBoxShow("配送企业对码失败！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        #endregion

        #region 2.系统事件方法
        private void frmEnterpriseCodeCheck_Load(object sender, EventArgs e)
        {
            _init();
        }

        private void btSave_Click(object sender, EventArgs e)
        {
            _save();
        }

        private void btnReturn_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        #endregion
    }
}
